package com.dlc.yunguang.adapter;

import android.view.View;
import android.widget.Button;
import com.dlc.commonlibrary.adapter.BaseRecyclerAdapter;
import com.dlc.yunguang.net.bean.AddHandworkData;
import com.dlc.yunguang.R;

/**
 * Created by John on 2017/7/24.
 */

public class AddHandworkAdapter extends BaseRecyclerAdapter<AddHandworkData> {
    private OnItemClickListener onItemClickListener;
    @Override
    public int getItemLayoutId(int viewType) {
        return R.layout.item_add_handwork;
    }

    @Override
    public void onBindViewHolder(CommonHolder holder,final int position) {
        AddHandworkData item = getItem(position);
        holder.setText(R.id.serial, (position+1)+"");
        holder.setText(R.id.product_name, item.goods_name);
        holder.setText(R.id.number, item.nums);
        Button delete = holder.getView(R.id.delete);
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null){
                    onItemClickListener.onClick(position);
                }
            }
        });

    }

    public interface OnItemClickListener {
        void onClick(int position);
    }
    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener=onItemClickListener;

    }
}
